package deepr.handler;


import deepr.core.DisposeContext;
import deepr.filter.FilterParser;
import deepr.lib.CastLib;
import deepr.lib.FilterLib;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class JsonKeySnowIdHandler extends PropertyHandler {

    @Override
    public Object filter(FilterParser parser, String key, Object value, Object params) {
        log.debug("key:{},value:{},params:{}", key, value, params);
        if (key.endsWith("'id'")) {
            parser.setHandlerJsonKey(FilterLib.jsonKeyToInt(key));
            return CastLib.toInteger(key, value);
        }
        return value;
    }

    public Object replyBefore(DisposeContext ctx, String object, String key, Object row) {
        return row;
    }

}
